package top.humbleyuan.test.demo;

import java.util.*;

/**
 * @Author HumbleYuan
 * @Date 2020/4/20 22:57
 * @Des
 */
public class T1 {

    /**
     * 给一个字符串，找出出现次数最多的字符。如果存在几个出现次数相同的字符，返回最早出现的字符
     * @param args
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while(sc.hasNext()) {
            String s = sc.nextLine();

            HashMap<Character, Integer> map = new HashMap<>();

            int max = 0;
            for (int i = 0; i < s.length(); i++) {
                map.put(s.charAt(i), map.getOrDefault(s.charAt(i), 0) + 1);
                max = Math.max(map.get(s.charAt(i)), max);
            }

            HashSet<Character> set = new HashSet<>();

            for (Character c : map.keySet()) {
                if(max == map.get(c)) {
                    set.add(c);
                }
            }

            if(set.size() == 1) {
                for (Character c :set) {
                    System.out.println(c);
                }
                System.out.println();
                return;
            }

            for (int i = 0; i < s.length(); i++) {
                if(set.contains(s.charAt(i))) {
                    System.out.println(s.charAt(i));

                    return;
                }
            }
        }

        sc.close();
    }
}
